import  { useState, useEffect } from 'react';

export const useValidateCode = () => {
  const [seconds, setSeconds] = useState(0);

  useEffect(() => {
    if (seconds > 0) {
      const timerId = setTimeout(() => {
        setSeconds(prevSeconds => prevSeconds - 1);
      }, 1000);
      return () => clearTimeout(timerId); // 清除定时器
    }
  }, [seconds]);

  return  { seconds, setSeconds };
};

